package ithink.link.base;

import ithink.link.base.service.ILinkServerListener;
import ithink.link.base.service.LinkServerConfig;
import ithink.link.base.service.LinkServerHelper;
import ithink.link.base.service.ServerState;
import org.apache.log4j.PropertyConfigurator;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;

import java.io.ByteArrayOutputStream;

/**
 * Created by zaqb on 17-10-23.
 */
public class Test {
    public static void main(String[] args) throws Exception {
        PropertyConfigurator.configure("/home/zaqb/workspace/itk_link/base/src/main/resources/log4j.properties");

        Serializer serializer = new Persister();
        ByteArrayOutputStream stream = new ByteArrayOutputStream();

//        LinkServerConfig server = new LinkServerConfig();
//        server.setServerName( "za" );
//        server.setExternalIp( "127.0.0.1" );
//        server.setInternalIp( "127.0.0.1" );
//        server.setMaxAccessCount( 10000 );
//        server.setUserPort( 443 );
//        server.setWebPort( 80 );
//        serializer.write(server, stream);
//        System.out.printf( new String(stream.toByteArray()) );

        LinkServerHelper serverHelper = new LinkServerHelper("t1", "0.1");
        serverHelper.init(new ILinkServerListener() {
            public void onStateChanged(LinkServerConfig config, ServerState oldState, ServerState newState) {

            }

            public void onConfigChanged(LinkServerConfig config) {

            }
        } );
        serverHelper.publish();
        Thread.sleep( 1000*1000 );
    }
}
